/*
 * @Author: Starfish_DL
 * @Date: 2020-10-29 20:40:46
 * @LastEditors: Starfish_DL
 * @LastEditTime: 2020-11-06 14:49:44
 * @CurrentVersion: 1.0
 * @Description: 
 */

#include <iostream>
using namespace std;

class TSBNode
{
public:
    TSBNode *hp; //brother
    TSBNode *vp; //son
    int data;
    TSBNode(int a);
    TSBNode(int a, TSBNode *h, TSBNode *v);
    ~TSBNode();
};

TSBNode::TSBNode(int a)
{
    this->data = a;
    this->hp = nullptr;
    this->vp = nullptr;
}

TSBNode::TSBNode(int a, TSBNode *h, TSBNode *v)
{
    this->data = a;
    this->hp = h;
    this->vp = v;
}

TSBNode::~TSBNode()
{
}

int treeH(TSBNode *v)
{
    if (v == nullptr)
    {
        return 0;
    }
    else
    {
        if (treeH(v->vp) + 1 >= treeH(v->hp) || v->hp == nullptr)
        {
            return treeH(v->vp) + 1;
        }
        else
        {
            return treeH(v->hp);
        }
    }
}

int treeN(TSBNode *v)
{
    if (v == nullptr)
    {
        return 0;
    }
    else
    {
        int temp = 0;
        TSBNode *p = v;
        while (p != nullptr)
        {
            temp++;
            temp += treeN(p->vp);
            p = p->hp;
        }
        return temp;
    }
}

void deleteTree(TSBNode *v)
{
    if (v == nullptr)
    {
        return;
    }
    else
    {
        TSBNode *p = v;
        TSBNode *pre = v->vp;
        while (pre != nullptr)
        {
            deleteTree(p->hp);
            delete p;
            p = pre;
            pre = pre->vp;
        }
        deleteTree(p->hp);
        delete p;
    }
}

class TSBTree
{
public:
    TSBNode *root;
    TSBTree();
    TSBTree(int a);
    ~TSBTree();
    int treeHeight();
    int treeNumber();
};

TSBTree::TSBTree()
{
    this->root = new TSBNode(1);
    TSBNode *p1 = new TSBNode(1);
    root->vp = p1;
    TSBNode *p2 = new TSBNode(1);
    p1->vp = p2;
    TSBNode *p3 = new TSBNode(1);
    p1->hp = p3;
    TSBNode *p4 = new TSBNode(1);
    p3->hp = p4;
    TSBNode *p5 = new TSBNode(1);
    p2->vp = p5;
    TSBNode *p6 = new TSBNode(1);
    p4->vp = p6;
    TSBNode *p7 = new TSBNode(1);
    p6->vp = p7;
    TSBNode *p8 = new TSBNode(1);
    p7->vp = p8;
    TSBNode *p9 = new TSBNode(1);
    p8->vp = p9;
    TSBNode *p10 = new TSBNode(1);
    p3->vp = p10;
}

TSBTree::TSBTree(int a)
{
    this->root = new TSBNode(a);
}

TSBTree::~TSBTree()
{
    deleteTree(this->root);
}

int TSBTree::treeHeight()
{
    return treeH(this->root);
}

int TSBTree::treeNumber()
{
    return treeN(this->root);
}

int main()
{
    TSBTree t1 = TSBTree();
    cout << t1.treeHeight() << endl;
    cout << t1.treeNumber() << endl;
    return 0;
}
